<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCashesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cashes', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')
                ->references('id')->on('agents');
            $table->tinyInteger('cash_type')->comment('1=账户充值 2=账户扣款 3=订单消费');
            $table->integer('amount')->comment('帐变金额');
            $table->integer('before_amount')->comment('之前金额');
            $table->integer('after_amount')->comment('之后金额/当前余额');
            $table->integer("created_at");
            $table->integer("updated_at");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cashes');
    }
}
